package edu.gatech.cs2340.teamrocket.view.main;

import edu.gatech.cs2340.teamrocket.model.Model;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.List;
import javax.swing.*;

/**
 * This is the top panel of the main game panel
 * @author Wai Chip Ngai
 *
 */
@SuppressWarnings("serial")
public class TopPanel extends JPanel{

    private JTextArea theAwesomeStatusBox;
    public TopPanel(){
        setPreferredSize(new Dimension(1024, 120));
        setLayout(new GridLayout(1,1));
        setBorder(BorderFactory.createLineBorder(Color.black));
        theAwesomeStatusBox = new JTextArea();
        //theAwesomeStatusBox.setRows(5);
        //theAwesomeStatusBox.setColumns(70);
        theAwesomeStatusBox.setText(" [Turn 1]\tYou will travel across the land, searching far and wide...");
        theAwesomeStatusBox.setEditable(false);
        JScrollPane theScrollingBox = new JScrollPane(theAwesomeStatusBox);
        theScrollingBox.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        add(theScrollingBox);
    }

    /*
    private String getTime(){
        long currentTime = System.currentTimeMillis();
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(currentTime);
        Date date = cal.getTime();
        DateFormat format = new SimpleDateFormat("h:mm:ss");
        String formattedDate = format.format(date);
        return formattedDate;
    }
    */

    public void updateLabel(String aString){
        theAwesomeStatusBox.append("\n [Turn " + Model.getInstance().getTurn() + "]\t" + aString);
    }

    public void setLabel(String s){
        theAwesomeStatusBox.setText(s);
    }

    public void setLabel(List<String> list){
        theAwesomeStatusBox.setText(" [Turn 1]\tYou will travel across the land, searching far and wide...");
        for(String s : list)
            updateLabel(s);
    }
}